﻿using Microsoft.AspNetCore.Http;
using System.Web;
using Yes.Core.Context;

namespace Yes.Core.Helper
{
    public static class SessionHelper
    {
        /// <summary>
        /// 添加Session，调动有效期为20分钟
        /// </summary>
        /// <param name="strSessionName">Session对象名称</param>
        /// <param name="strValue">Session值</param>
        public static void Add(string strSessionName, string strValue)
        {
            YesHttpContext.Current.Session.SetString(strSessionName, strValue);
            //HttpContext.Current.Session.Timeout = 20;
        }



        /// <summary>
        /// 读取某个Session对象值
        /// </summary>
        /// <param name="strSessionName">Session对象名称</param>
        /// <returns>Session对象值</returns>
        public static object Get(string strSessionName)
        {
            return YesHttpContext.Current.Session.GetString(strSessionName);
        }



        /// <summary>
        /// 删除某个Session对象
        /// </summary>
        /// <param name="strSessionName">Session对象名称</param>
        public static void Del(string strSessionName)
        {
            YesHttpContext.Current.Session.Remove(strSessionName);
        }
    }
}